package exception;

import org.slf4j.LoggerFactory;

public class Test {
    public static void main(String[] args) {
        try{
            Thread thread1 = new Thread(new AThread());
            /*thread1.setUncaughtExceptionHandler((t, e) -> {
                //LoggerFactory.getLogger(t.getName()).error(e.getMessage(), e);
                System.out.println(t + " throws exception: " + e);
            });*/
            thread1.start();
        }catch (Exception e){
            System.out.println("Exception has been handled!");
        }
    }
}

class AThread implements Runnable{
    @Override
    public void run() {
        throw new RuntimeException("线程中的错误");
    }
}